tools/lib/api/fs/fs.c: Fix misuse of strncpy()
authorBen Hutchings <ben@decadent.org.uk>
Thu, 19 Jul 2018 22:36:52 +0000 (23:36 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Sat, 7 Dec 2019 12:24:06 +0000 (12:24 +0000)
commitc7a6d5eb2d25a0d192f39cc1719ec77932c5f16c
tree27306021d2315371d7e82d6ae4326679d1563e9b
parent5b8c89bb708c8d88b96874ee3963d0beea5c74a7
tools/lib/api/fs/fs.c: Fix misuse of strncpy()

gcc 8 reports:

In function 'fs__env_override',
    inlined from 'fs__get_mountpoint' at fs/fs.c:228:6:
fs/fs.c:222:2: error: 'strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation]
  strncpy(fs->path, override_path, sizeof(fs->path));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm not convinced it makes sense to truncate the copied string here,
but since we're already doing so let's ensure it's still null-
terminated.  Use strlcpy() instead.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name tools-lib-api-fs-fs.c-fix-misuse-of-strncpy.patch
tools/lib/api/fs/fs.c